package com.hjq.bar.demo.slice;

import com.hjq.bar.OnTitleBarListener;
import com.hjq.bar.TitleBar;
import com.hjq.bar.demo.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.window.dialog.ToastDialog;

public class MainAbilitySlice extends AbilitySlice {
  @Override
  public void onStart(Intent intent) {
    super.onStart(intent);
    super.setUIContent(ResourceTable.Layout_ability_main);
    TitleBar titleBar = (TitleBar) findComponentById(ResourceTable.Id_tb_main_bar);
    titleBar.setOnTitleBarListener(new OnTitleBarListener() {
      @Override
      public void onLeftClick(Component view) {
        new ToastDialog(getContext()).setText("左项 View 被点击").show();
      }

      @Override
      public void onTitleClick(Component view) {
        new ToastDialog(getContext()).setText("中间 View 被点击").show();
      }

      @Override
      public void onRightClick(Component view) {
        new ToastDialog(getContext()).setText("右项 View 被点击").show();
      }
    });
  }

  @Override
  public void onActive() {
    super.onActive();
  }

  @Override
  public void onForeground(Intent intent) {
    super.onForeground(intent);
  }
}
